<template>
	<el-container v-if="isAlready" ref="mainBody">
	  <el-header>
		<div class="left-panel">
		  <fsButton ref="button" plain size="default" :buttons="buttons" @clickHandler="buttonHandler"></fsButton>
		</div>
		<div class="right-panel">
			<ex-search ref="search" :searches="searches" @searchOk="searchHandler" default-code="searchKeyword" placeholder="请输入关键字搜索" :fixedParam="fixedParams" :initParams="searchParams">
				<template v-if="cardName === '资产台账'">
					<el-checkbox v-model="tempParams.showXuli" class="searchcheckbox"
								 @change="searchHandler">显示虚拟账套
					</el-checkbox>
					<el-checkbox v-model="tempParams.excludeBorrow"   class="searchcheckbox"
								 @change="searchHandler">排除借用资产
					</el-checkbox>
				</template>
				<template v-if="cardName === '房产台账'">
					<el-checkbox v-model="tempParams.showXuli" class="searchcheckbox"
								 @change="searchHandler">显示虚拟账套
					</el-checkbox>
				</template>
				<template v-if="cardName === '配件台账'">
<!--					<el-select v-model="tempParams.isBindMainAsset" class="searchcheckbox" placeholder="全部配件" @change="searchHandler" clearable>-->
<!--						<el-option label="未关联主资产" value="0"></el-option>-->
<!--						<el-option label="已关联主资产" value="1"></el-option>-->
<!--					</el-select>-->
				</template>

<!--					包含删除资产<el-switch-->
<!--					v-model="tempParams.includeDelete"-->
<!--					style="&#45;&#45;el-switch-on-color: #13ce66; &#45;&#45;el-switch-off-color: #c9c9c9"-->
<!--					:active-value="true"-->
<!--					:inactive-value="false" @change="searchHandler">-->
<!--					</el-switch>-->
			</ex-search>
		</div>
	  </el-header>
	  <el-main class="nopadding">
		<el-container>

<!--		  <el-aside class="nopadding"  style="min-width:300px;width: 18%;">-->
<!--			<ex-search-tree ref="searchTree" :treeApi="this.$API.asset.column.treeData" @changeHandler="searchTreeHandler" :param="{isGroup:'1'}">-->
<!--			</ex-search-tree>-->
<!--		  </el-aside>-->
		  <el-main class="nopadding" style="overflow: hidden;">
			<el-header v-if="headerRow" style="height: 100px;padding-top: 0px;padding-bottom: 0px;padding-left: 1%;padding-right: 1%;">
				<el-row :md="24" :lg="24" class="headerRow">
					<el-col :lg="4" v-for="(item, index) in headerArray" class="headerCol">
						<div style="width: 100%;height: 90%;padding-left: 5%;padding-right: 5%;">
							<div class="statusname">{{item.assetStatusId}}</div>
							<div class="countname">{{formatNumber(item.assetCount)}}</div>
							<div><span>净值:</span>{{formatNumber(item.netValue)}}</div>
						</div>
					</el-col>
				</el-row>
			</el-header>
			<ex-table id="assetTable" ref="table" :columns="columns" :url="this.$API.asset.asset.list.url" :refs="this.$refs" search="search" :headerRow="headerRow" :params="{deptIds:this.readDeptIds,assetCategoryIds:this.readAssetCategoryIds,assetStatusIds:this.readAssetStatusIds}" @columnClick="columnClickHandler" @onMounted="exTableMountedHandler"></ex-table>
		  </el-main>
		</el-container>
	  </el-main>
	</el-container>

  <data-card ref="dataCard"></data-card>

  </template>

  <script>
  import ExTable from "@/components/exTable/index.vue";
  import ExSearch from "@/components/exSearch/index.vue";
  import ExTreeNavigation from "@/components/exSearchTree/index.vue";
  import ExSearchTree from "@/components/exSearchTree/index.vue";
  import DataCard from "@/views/asset/card/card.vue";
  import formRule from "@/utils/formRule";
  import useTabs from "@/utils/useTabs";
  import constant from "@/constant";
  import BaseTemplate from "@/utils/baseTemplate";
  //import dict from "@/utils/dict";

  export default {
	name: '资产台账',
	components: {
    DataCard,
	  ExSearchTree,
	  ExTreeNavigation,
	  ExSearch,
	  ExTable,
	},
	data() {
	  return {
		dialog: {
		  save: false,
		  permission: false
		},
		apiObj: [],
		buttons: [
        	{name: this.$t('button.export'), icon: "el-icon-download", type: "info", click: "export", permission: ""},
			    {name: "国资委导出", icon: "el-icon-download", click: "gzwExport",  type: "info", permission: "gzwExport"},
		],
		searches: [
		  {type: "input", name: "资产名称", code: "name", placeholder: "请输入资产名称",},
		  // {type: "input", name: "资产编码", code: "code", placeholder: "请输入资产编码",maxlength: 30, showLimit: true},
		  {type: "input", name: "资产编码", code: "code", placeholder: "请输入资产编码"},
		  {type: "input", name: "主资产编码", code: "mainAssetCode", placeholder: "请输入主资产编码"},
		  {type: "input", name: "华士资产编码", code: "other.huaShiCode", placeholder: "请输入华士资产编码"},
		  {type: "input", name: "财务编码", code: "financialCode", placeholder: "请输入财务编码"},
		  {type: "input", name: "财务条形码", code: "other.financialBarCode", placeholder: "请输入财务编码"},
		  {type: "select", name: "华士盘点结果", code: "other.huaShiCheckResult", placeholder: "请选择华士盘点结果", dictCode:'HUASHI_CHECK_RESULT'},
			{type: "select", name: "账务类型", code: "other.financialType", placeholder: "请选择账务类型", dictCode:'FINANCIAL_TYPE'},
			{type: "select", name: "借用类型", code: "borrowType", placeholder: "请选择借用类型", dictCode:'ASSET_BORROW_TYPE'},
			{type: "input", name: "入库单号", code: "other.inDocumentCode", placeholder: "请输入入库单号"},
			{type: "input", name: "申购单号", code: "other.purchaseOrderCode", placeholder: "请输入申购单号"},
			// {type: "input", name: "排量", code: "other.carDisplacement", placeholder: "请输入排量"},
			// {type: "input", name: "车牌号", code: "other.carPlateNumber", placeholder: "请输入车牌号"},
			// {type: "input", name: "车架号", code: "other.cardStructNumber", placeholder: "请输入车架号"},
			// {type: "input", name: "发动机号", code: "other.carEngineNumber", placeholder: "请输入发动机号"},
			{type: "tree-select", name: "资产分类", code: "assetCategoryIds",dictCode:'FamsAssetCategory',priKey:true,dataRange:'all',multiple:true},
			{type: "input", name: "规格型号", code: "model", placeholder: "请输入规格型号"},
			{type: "input", name: "品牌", code: "brand", placeholder: "请输入品牌"},
			{type: "tree-select", name: "管理部门", code: "dutyDepartmentIds",dictCode:'SysOrganization',priKey:true,dataRange:'all',multiple:true},
			{type: "selector", name: "管理人", code: "dutyMenId",dictCode:'SysUser'},
			{type: "tree-select", name: "使用部门", code: "usingDepartmentIds",dictCode:'SysOrganization',priKey:true,dataRange:'all',multiple:true},
			{type: "selector", name: "使用人", code: "usingMenId",dictCode:'SysUser'},
			{type: "tree-select", name: "借用部门", code: "borrowingDepartmentIds",dictCode:'SysOrganization',priKey:true,dataRange:'all',multiple:true},
			{type: "selector", name: "借用人", code: "other.borrowingMenId",dictCode:'SysUser'},
			{type: "select", name: "资产状态", code: "assetStatusIds", placeholder: "请选择资产状态", dictCode:'ASSET_STATUS',multiple:true},
			{type: "tree-select", name: "位置", code: "storePlaceIds",dictCode:'FamsPosition',checkStrictly:true,multiple:true},
			{type: "daterange", name: "入库日期", code: "zcrkDateStart,zcrkDateEnd",valueFormat:"YYYYMMDD",format:"YYYY-MM-DD",range:365},
			{type: "daterange", name: "购置日期", code: "boughtDateStart,boughtDateEnd",valueFormat:"YYYYMMDD",format:"YYYY-MM-DD",range:365},
			{type: "daterange", name: "闲置日期", code: "zcxzDateStart,zcxzDateEnd",valueFormat:"YYYYMMDD",format:"YYYY-MM-DD",range:365},
			{type: "daterange", name: "借用日期", code: "zcjyDateStart,zcjyDateEnd",valueFormat:"YYYYMMDD",format:"YYYY-MM-DD",range:365},
		  {type: "daterange", name: "报废日期", code: "scrapDateStart,scrapDateEnd",valueFormat:"YYYYMMDD",format:"YYYY-MM-DD",range:365},
		],
		columns: [
		  {code: "assetStatusId", name: "资产状态", width:"75",formatter:"DICT",key: "ASSET_STATUS"},
		  {code: "code", name: "资产编码", width:"130",click:"show1"},
		  {code: "financialCode", name: "财务编码", width:"120"},
		  {code: "name", name: "资产名称", width:"200"},
		  // {code: "isLocked", name: "操作状态", width:"80",formatter:"DICT",key: "IS_LOCKED"},
		  {code: "storePlaceId", name: "资产位置",width: "120", formatter:"DICT",key: "FamsPosition"},
		  {code: "mainCategoryCode", name: "资产大类",width:"150", formatter:"DICT",key: "FamsAssetCategory"},
		  {code: "assetCategoryId", name: "资产分类",width:"150", formatter:"DICT",key: "FamsAssetCategory"},
		  {code: "other.financialType", name: "账务类型",width: "75", formatter:"DICT",key: "FINANCIAL_TYPE"},
		  {code: "other.financialBarCode", name: "财务条形码", width:"120"},
		  {code: "other.purchaseOrderCode", name: "申购单号", width:"150"},
		  {code: "brand", name: "品牌", width:"100"},
		  {code: "model", name: "规格型号", width:"150"},
		  {code: "serialCode", name: "资产序列号", width:"150"},
		  {code: "assetCount", name: "数量", width:"60",summary:true},
		  {code: "originalValue", name: "原值", width:"100",summary:true},
		  {code: "netValue", name: "净值", width:"100",summary:true},
		  // {code: "usingMenCode", name: "使用人工号", width:"100"},
		  {code: "usingMenId", name: "使用人", width:"80",formatter: "DICT",key: "SysUser"},
		  {code: "usingDepartmentId", name: "使用部门", width:"100",formatter: "DICT",key: "SysOrganization"},
		  {code: "dutyDepartmentId", name: "责任部门", width:"100",formatter: "DICT",key: "SysOrganization"},
		  {code: "dutyMenId", name: "责任人", width:"80",formatter: "DICT",key: "SysUser"},
		  // {code: "dutyDepartmentId", name: "借用部门", width:"100",formatter: "DICT",key: "SysOrganization"},
		  // {code: "dutyMenId", name: "借用人", width:"80",formatter: "DICT",key: "SysUser"},
		  // {code: "dutyDepartmentId", name: "受益部门", width:"100",formatter: "DICT",key: "SysOrganization"},
		  // {code: "dutyMenId", name: "受益人", width:"80",formatter: "DICT",key: "SysUser"},
		  {code: "other.inDocumentCode", name: "入库单号", width:"120"},
		  {code: "createUser", name: "入库人", width:"80",formatter: "DICT",key: "SysUser"},
		  {code: "createTime", name: "入库日期", width:"95",formatter: "DATE"},
		  {code: "boughtDate", name: "购置日期", width:"95",formatter: "DATE"},
		  // {code: "dutyMenId", name: "采购日期", width:"95",formatter: "DATE"},
		  {code: "other.zcxzDate", name: "闲置日期", width:"95",formatter: "DATE"},
		  {code: "other.zcjyDate", name: "借用日期", width:"95",formatter: "DATE"},
		  {code: "other.scrapDate", name: "报废日期", width:"95",formatter: "DATE"},
		  {code: "other.zcdbDate", name: "调拨日期", width:"95",formatter: "DATE"},
		],
		parentLevelCode:"",
    	assetIds:[],
	    isAlready:false,
		readAssetCategoryIds:[],
		readAssetStatusIds:[],
		readDeptIds:this.$TOOL.current.readDeptIds(),
		fixedParams:{},
		searchParams:{},
		  cardName: '',
		tempParams:{excludeStatus:['delete'],showXuli:false},
		headerRow:false,
		headerArray:[],
	  }
	},
	  created() {
		//如果是通过跳转过来的，标签的名称设置为跳转后的标题
		let routeParams = this.$store.state.routeParams[this.$route.params.key];
		if (routeParams) {
			if (routeParams.title) {
				useTabs.setTitle(routeParams.title);
				document.title = routeParams.title;
			}
			if (routeParams.fixedParams) {
				Object.assign(this.fixedParams, routeParams.fixedParams);
			}
			if (routeParams.showXuli) {
				this.tempParams.showXuli = routeParams.showXuli;
			}
			if (routeParams.searchParams) {
				Object.assign(this.searchParams, routeParams.searchParams);
			}
			this.buttons = [
				{name: this.$t('button.export'), icon: "el-icon-download", type: "info", click: "export"},
			]
		}

		Object.assign(this.searchParams, this.tempParams);

	},
	async mounted() {
		try {
			if (this.$route.meta.relTemplateId) {
				//读取卡片信息
				let card = await this.$cache.data.loadDataCard(this.$route.meta.relTemplateId);
				if (card) {
					this.cardName = card.name;
					let columns = card.modules[0].widgets[0].props.columns;
					if (columns) {
						columns.forEach(column => {
							formRule.updateColumnFormatter(column);
						});
						this.columns = columns;
					}
				} else {
					this.$message.error(this.$t('common.config_error'));
					useTabs.close();
				}
			}
			//限定查询资产分类的范围
			this.readAssetCategoryIds = await this.currentAssetCategoryIds();
			if (this.fixedParams.assetCategoryIds) {
				this.readAssetCategoryIds = this.fixedParams.assetCategoryIds;
				this.searches.forEach(item => {
					if (item.code === 'assetCategoryIds') {
						item.permissionData = this.readAssetCategoryIds;
					}
				})
			}
			//限定查询部门的范围
			if (this.fixedParams.deptIds) {
				this.readDeptIds = this.fixedParams.deptIds;
				this.searches.forEach(item => {
					if (item.code === 'usingDepartmentIds') {
						item.permissionData = this.readDeptIds;
					}
					if (item.code === 'dutyDepartmentIds') {
						item.permissionData = this.readDeptIds;
					}
					if (item.code === 'borrowingDepartmentIds') {
						item.permissionData = this.readDeptIds;
					}
				})
			}
			//限定查询资产状态的范围
			this.readAssetStatusIds = await this.currentAssetStatusIds();
			if(this.readAssetStatusIds.includes("delete")){
				this.tempParams.includeDelete===true
				this.tempParams.excludeStatus = this.tempParams.excludeStatus.filter(item=>item!=='delete');
				Object.assign(this.searchParams, this.tempParams);
			}
			if (this.fixedParams.assetStatusIds) {
				this.readAssetStatusIds = this.fixedParams.assetStatusIds;
				this.searches.forEach(item => {
					if (item.code === 'assetStatusIds') {
						item.permissionData = this.readAssetStatusIds;
					}
				})
			}

			if(this.cardName === '在库台账'){

			}else if(this.cardName === '资产台账'){
				this.headerRow=true;
			}
			else if(this.cardName === '车辆台账'){
				this.headerRow=true;
				this.searches.splice(10,0,{type: "input", name: "排量", code: "other.carDisplacement", placeholder: "请输入排量"});
				this.searches.splice(10,0,{type: "input", name: "车牌号", code: "other.carPlateNumber", placeholder: "请输入车牌号"});
				this.searches.splice(10,0,{type: "input", name: "车架号", code: "other.cardStructNumber", placeholder: "请输入车架号"});
				this.searches.splice(10,0,{type: "input", name: "发动机号", code: "other.carEngineNumber", placeholder: "请输入发动机号"});
			}else if(this.cardName === '配件台账'){
        		this.fixedParams.isAccessory = '1';//只查配件
				this.searches.splice(0,0,{type: "select", name: "关联状态", code: "isBindMainAsset", placeholder: "全部配件",ops:[{label: "未关联主资产",value: "0"},{label: "已关联主资产",value: "1"}]});
      		}

			this.isAlready = true;
		} catch (err) {
			this.$message.error(this.$t('common.config_error'));
			useTabs.close();
			console.log(err);
		}
	},
	  methods: {
      exTableMountedHandler(){
        if(this.headerRow){
		    this.headerArray=[];
        let statisticsParams = this.$refs.table.queryParams(this.tempParams);
        this.$API.asset.asset.selectAssetStateStatistics.post(statisticsParams).then((rsp) =>{
          if(rsp.code === 2000){
            console.log("统计数据->",rsp.data)

              rsp.data.forEach(item => {
                if(item.assetStatusId!="删除"){
                  if(item.assetStatusId=="总资产"){
                    item["sort"]=0;
                  }
                  if(item.assetStatusId=="在用"){
                    item["sort"]=1;
                  }
                  if(item.assetStatusId=="在库"){
                    item["sort"]=2;
                  }
                  if(item.assetStatusId=="借用"){
                    item["sort"]=3;
                  }
                  if(item.assetStatusId=="闲置"){
                    item["sort"]=4;
                  }
                  if(item.assetStatusId=="报废"){
                    item["sort"]=5;
                  }
                  this.headerArray.push(item);
                }
              });
              this.headerArray=this.headerArray.sort(function(a, b){
                return a.sort - b.sort
              })
          }
          });

        }
      },
	  buttonHandler(index, name) {
		this.$options.methods[name](this, index);
	  },
	  async searchTreeHandler(data) {
		let queryParams = {pathCode:data.levelCode}
		this.parentLevelCode= data.levelCode;
		await this.$refs.table.refresh(queryParams);
	  },
		  //获取可查看的资产状态
		  async currentAssetStatusIds() {
			  let readAssetStatusIds = [];
			  if(this.$route.meta.relTemplateId){
				  //读取操作的资产分类
				  let queryDto = {
					  firstEntity: constant.entity.FamsAssetCard.name,
					  firstEntityId: this.$route.meta.relTemplateId,
					  secondEntity: "AssetLedgerAssetStatus",
				  };
				  let rsp = await this.$API.system.relMap.load.post(queryDto);
				  if (rsp.code === 2000 && Array.isArray(rsp.data)) {
					  rsp.data.forEach(item => {
						  readAssetStatusIds.push(item.secondEntityId);
					  });
				  }
			  }
			  return readAssetStatusIds;
		  },
		//获取可操作的资产类别
		async currentAssetCategoryIds() {
			  let cardCategoryIds = [];
		      if(this.$route.meta.relTemplateId){
				  //读取操作的资产分类
				  let queryDto = {
					  firstEntity: constant.entity.FamsAssetCard.name,
					  firstEntityId: this.$route.meta.relTemplateId,
					  secondEntity: "AssetLedgerCategory",
				  };
				  let rsp = await this.$API.system.relMap.load.post(queryDto);
				  if (rsp.code === 2000 && Array.isArray(rsp.data)) {
					  rsp.data.forEach(item => {
						  cardCategoryIds.push(item.secondEntityId);
					  });
				  }
			  }

			  let roleManageAssetCategoryIds = this.$TOOL.current.manageAssetCategoryIds();
			  //如果当前角色有管理资产类别限制，单据也有管理资产类别限制，则取两者的交集，否则直接使用单据的资产类别限制
			  let realAssetCategoryIds = {};
			  if (roleManageAssetCategoryIds && cardCategoryIds) {
				  if (Array.isArray(roleManageAssetCategoryIds)) {
					  roleManageAssetCategoryIds.forEach(item => {
						  realAssetCategoryIds[item] = true;
					  });
				  }
				  if (Array.isArray(cardCategoryIds)) {
					  for (let item in realAssetCategoryIds) {
						  if (!cardCategoryIds.includes(item)) {
							  delete realAssetCategoryIds[item];
						  }
					  }
				  }
				  cardCategoryIds = [];
				  for (let item in realAssetCategoryIds) {
					  cardCategoryIds.push(item);
				  }
			  }
			  return cardCategoryIds;
		},
	  async searchHandler() {
		  this.tempParams.pathCode=this.parentLevelCode;

		  //重新设置排除借用状态
		  this.tempParams.excludeStatus = this.tempParams.excludeStatus.filter(item=>item!=='borrow');
		  if(this.tempParams.excludeBorrow===true){
			  this.tempParams.excludeStatus.push('borrow');
		  }

		  //重新设置包含删除资产状态
		  this.tempParams.excludeStatus = this.tempParams.excludeStatus.filter(item=>item!=='delete');
		  if(this.tempParams.includeDelete!==true){
			  this.tempParams.excludeStatus.push('delete');
		  }

		  //资产状态统计
		  this.exTableMountedHandler();
		  await this.$refs.table.refresh(this.tempParams);
	  },

	  columnClickHandler(name,data){
		this.$options.methods[name](this, data);
	  },
	//查看
	async show1(_this, row) {
    let assetCategory = await _this.$cache.data.loadAssetCategory(row.assetCategoryId);
    try {
      _this.loading = true;
      let entity = {cardId: assetCategory.assetCardId, _editFlag: false}
      _this.$nextTick(() => {
        _this.cardPreview = false;
        _this.$refs.dataCard.open(Object.assign(entity, row));
      });
    } finally {
      _this.loading = false;
    }
  },
      //查看
      async showMainAsset(_this, row) {
        if(!row.mainAssetId){
          return;
        }
        //查询主资产信息
        let mainAssetRes = await _this.$API.asset.asset.findById.post({id: row.mainAssetId});
        if(mainAssetRes.code===2000){
          let mainAsset = mainAssetRes.data;
          let assetCategory = await _this.$cache.data.loadAssetCategory(mainAsset.assetCategoryId);
          try {
            _this.loading = true;
            let entity = {cardId: assetCategory.assetCardId, _editFlag: false}
            _this.$nextTick(() => {
              _this.cardPreview = false;
              _this.$refs.dataCard.open(Object.assign(entity, mainAsset));
            });
          } finally {
            _this.loading = false;
          }
        }
      },
    //导出
    async export(_this,index) {
      let attachParams = {};
      if(_this.cardName === '车辆台账'){
        attachParams.exportType = 'carAsset';
      }else if(_this.cardName === '房产台账'){
        attachParams.exportType = 'realEstateAsset';
      }else if(_this.cardName === '在库台账'){
        attachParams.exportType = 'storeAsset';
      }else if(_this.cardName === '配件台账'){
        attachParams.exportType = 'accessoryAsset';
      }

      let exportApi = _this.$API.asset.asset.export;
      let exTableRef = _this.$refs.table;
      let exportBtnRef = _this.$refs.button;
      await BaseTemplate.export(_this, exportApi, attachParams, exportBtnRef, index, exTableRef);
    },

		  //国资委导出
		  async gzwExport(_this,index) {
        let attachParams = {};
        attachParams.exportType = 'gzwRealEstateAsset';
        let exportApi = _this.$API.asset.asset.export;
        let exTableRef = _this.$refs.table;
        let exportBtnRef = _this.$refs.button;
        await BaseTemplate.export(_this, exportApi, attachParams, exportBtnRef, index, exTableRef);
		  },
	  //批量删除
	  del(_this, index) {
      let selections = _this.$refs.table.selections();
      if (selections.length === 0) {
        _this.$message.warning(_this.$t("common.please_select_data"));
        return;
      }
      _this.$confirm(`确定删除选中的 ${selections.length} 项吗？如果删除项中含有子集将会被一并删除`, '警告', {
        type: 'warning'
      }).then(async () => {
        _this.$refs.button.loading(index, true);
        var delarray = [];
        for (let index = 0; index < selections.length; index++) {
          const element = selections[index];
          delarray.push(element.id);
        }
        var res = await _this.$API.asset.column.deleteByIds.post(delarray);
        if (res.code === 2000) {
          _this.$message.success(_this.$t("code."+res.code));
          _this.searchHandler();
		  _this.$store.dispatch("commit",selections[0].entityName);
        }
        _this.$refs.button.loading(index, false);
      }).catch(() => {
        _this.$refs.button.loading(index, false);
      });
    },
    //批量启用
    enabled(_this, index) {
      let selections = _this.$refs.table.selections();
      if (selections.length === 0) {
        _this.$message.warning(_this.$t("common.please_select_data"));
        return;
      }
      _this.$confirm(`确定启用选中的 ${selections.length} 项吗？`, '提示', {
        type: 'warning'
      }).then(async () => {
        _this.$refs.button.loading(index, true);
        var delarray = [];
        for (let index = 0; index < selections.length; index++) {
          const element = selections[index];
          delarray.push(element.id);
        }
        var res = await _this.$API.asset.column.enabled.post(delarray);
        if (res.code === 2000) {
          _this.$message.success(_this.$t("code."+res.code));
          _this.searchHandler();
		  _this.$store.dispatch("commit",selections[0].entityName);
        }
        _this.$refs.button.loading(index, false);
      }).catch(() => {
        _this.$refs.button.loading(index, false);
      });
    },
    //批量禁用
    disabled(_this, index) {
      let selections = _this.$refs.table.selections();
      if (selections.length === 0) {
        _this.$message.warning(_this.$t("common.please_select_data"));
        return;
      }
      _this.$confirm(`确定禁用选中的 ${selections.length} 项吗？`, '提示', {
        type: 'warning'
      }).then(async () => {
        _this.$refs.button.loading(index, true);
        var delarray = [];
        for (let index = 0; index < selections.length; index++) {
          const element = selections[index];
          delarray.push(element.id);
        }
        var res = await _this.$API.asset.column.disabled.post(delarray);
        if (res.code === 2000) {
          _this.$message.success(_this.$t("code."+res.code));
          _this.searchHandler();
		  _this.$store.dispatch("commit",selections[0].entityName);
        }
        _this.$refs.button.loading(index, false);
      }).catch(() => {
        _this.$refs.button.loading(index, false);
      });
	  },
	  formatNumber(val){
		if (!val) return '0';
		const parts = val.toString().split('.');
		parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
		return parts.join('.');
	}
	}
  }

  </script>
  <style>
.headerRow{
	width:100%;

  }
  .headerRow .headerCol{
	overflow-wrap: break-word;
    color: #fff;
	text-align: left;
	border:1px #edf2f7 solid;
	font-size: 14px;
    font-family: PingFangSC-Semibold;
    font-weight: 400;
	color: #666666;
	padding-bottom: 10px;

  }

  .headerRow .headerCol .statusname{
	margin-top: 10px;
    white-space: nowrap;
	margin-bottom: 10px;
	font-size: 17px;
	font-weight: 530;
	color: rgb(45, 55, 72);

  }
  .headerRow .headerCol .countname{
	font-size: 18px;
	margin-bottom: 6px;
	font-weight: 0;
	color: rgb(45, 55, 72);
  }
  .headerRow .headerCol span{
	color: #666666;
  }

  .searchcheckbox .el-checkbox__label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
</style>
